package com.xindaoapp.happypet.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;

public class ProgressView extends View {
	private float fArcNum;
	private float fMax;
	private float density;

	public float getDensity() {
		return density;
	}

	public void setDensity(float density) {
		this.density = density;
	}

	public ProgressView(Context context) {
		super(context);
	}

	public ProgressView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		Paint paint = new Paint();
		if (fArcNum > 0) {
			paint.setColor(Color.GRAY);
			paint.setFlags(Paint.ANTI_ALIAS_FLAG);
			canvas.drawCircle(40 * density / 2, 40 * density / 2, 40 * density / 2, paint);
		}
		paint.setColor(Color.YELLOW);
		paint.setFlags(Paint.ANTI_ALIAS_FLAG);
		// paint.setStrokeWidth(2);
		RectF rect = new RectF(0, 0, 40 * density, 40 * density);
		canvas.drawArc(rect, -90, fArcNum, true, paint);
		paint.setColor(Color.BLACK);
		paint.setFlags(Paint.ANTI_ALIAS_FLAG);
		canvas.drawCircle(40 * density / 2, 40 * density / 2, 40 * density / 2 - 5, paint);
	}

	public void setProgress(float num) {
		fArcNum = (num / fMax) * 360;
	}

	public float getfArcNum() {
		return fArcNum;
	}

	public void setfArcNum(float fArcNum) {
		this.fArcNum = fArcNum;
	}

	public float getfMax() {
		return fMax;
	}

	public void setfMax(float fMax) {
		this.fMax = fMax;
	}
}
